package com.chuyi.demo.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class FormLayoutSimple {

	public static void main(String[] args) {
		
		Display display = new Display();
		Shell shell = new Shell(display);
		
		FormLayout formLayout = new FormLayout();
		formLayout.marginHeight = 30;
		formLayout.marginWidth =10;
		
		shell.setLayout(formLayout);
		
		Button button = new Button(shell, SWT.PUSH);
		button.setText("Button");
		
		FormData formData = new FormData();
		formData.top = new FormAttachment(0, -30);
		formData.bottom = new FormAttachment(30, 0);
	
		
		//new FormAttarchment(1,-30) == new FormAttarchment(1,100,-30);
		
		button.setLayoutData(formData);
		
		shell.pack();
		shell.open();
		while(!shell.isDisposed()){
			if(!display.readAndDispatch()){
				display.sleep();
			}
		}
		display.dispose();
		
		
	}
}
